package com.ruoyi.common.core.domain.entity;

import com.ruoyi.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.List;

@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class AppUser extends BaseEntity {
	private static final long serialVersionUID = 1L;

	private Long userId;

	private Long deptId;

	private String userName;

	private String nickName;

	private String email;

	private String phonenumber;

	private String sex;

	private String avatar;

	private String password;

	private String salt;

	private String status;

	private String delFlag;

	private String loginIp;

	private Date loginDate;

	private SysDept dept;

	private List<SysRole> roles;

	private Long[] roleIds;

	private Long[] postIds;

	private Long roleId;

	public AppUser(Long userId) {
		this.userId = userId;
	}

	public boolean isAdmin() {
		return isAdmin(this.userId);
	}

	public static boolean isAdmin(Long userId) {
		return userId != null && 1L == userId;
	}
}
